import { request, conversation } from "@/utils/request.js"

/**
 *  Gpt排队
 * @returns {Promise<unknown>}
 * @param gptCode
 */
export const joinGtpQueueApi = gptCode => {
    return request({
        url: `/ht-nonrealtime-gameservice/htgpt/JoinGptQueue/${gptCode}`,
        timeout: 60000,
        method: 'POST',
    })
}

/**
 * 向gpt对话
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const chatToGptApi = data => {     
    return request({
        url: `/ht-nonrealtime-gameservice/htgpt/chatToGpt/${data.gptCode}`,
        enableChunked: true,
        timeout: 60000,
        method: 'POST',
        "content-type": "text/plain",
        data: {
            conversationId: data.conversationId,
            query: data.query,
        }
    })
    // return conversation({
    //     url: `/ht-nonrealtime-gameservice/htgpt/chatToGpt/${data.gptCode}`,
    //     enableChunked: true, // enableChunked必须为true
    //     timeout: 600000*100,
    //     method: 'POST',
    //     data
    // })
}

/**
 * 获取对话列表
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const getConversationListAPi = (data) => {
    return request({
        url: '/ht-nonrealtime-gameservice/htgpt/getConversations',
        timeout: 60000,
        method: 'POST',
        data
    })
}

/**
 * 获取会话内容
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const getConversationContentApi = data => {
    return request({
        url: '/ht-nonrealtime-gameservice/htgpt/getMessages',
        timeout: 60000,
        method: 'POST',
        data
    })
}

export const getDefaultQuestionAPi = () => {
    return request({
        url: '/ht-nonrealtime-gameservice/question/getQuestionList',
        timeout: 60000,
        method: 'POST'
    })
}
